package com.ny.demo506;

import javax.swing.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class Test {
    public static void main(String[] args) throws IOException {
        String data = "劳动节快乐";
        FileOutputStream outputStream = new FileOutputStream("1.txt");
        byte[] bytes = data.getBytes();
        outputStream.write(bytes);


        FileInputStream inputStream = new FileInputStream("1.txt");
        byte[] buffer = new byte[1024];
        StringBuffer conten = new StringBuffer();
//        append:拼接字符
        int length;
        while((length=inputStream.read(buffer))!=-1){
            conten.append(new String(buffer,0,length, StandardCharsets.UTF_8));

        }
        System.out.println(conten.toString());
    }
}
